package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.PlanTarget;
import com.indusfo.spc.service.PlanTargetService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author: 熊冰
 * @Date: 2019/11/9 13:12
 * 任务单流程采集参数
 */

@Controller
@RequestMapping("/planTarget")
public class PlanTargetController {
	@Autowired
	private PlanTargetService planTargetService;

	//查询
	@RequestMapping(value="/queryPlanTarget")
	@ResponseBody
	public JSONObject queryPlanTarget(PlanTarget planTarget) {
		JSONObject json = planTargetService.queryPlanTarget(planTarget);
		return json;
	}

	//新增
	@RequestMapping(value="/insertPlanTarget", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject insertPlanTarget(PlanTarget planTarget) {
		JSONObject json = planTargetService.insertPlanTarget(planTarget);
		return json;
	}

	//修改
	@RequestMapping(value = "/updatePlanTarget",method= RequestMethod.POST)
	@ResponseBody
	public JSONObject updatePlanTarget (PlanTarget planTarget){
		JSONObject json=planTargetService.updatePlanTarget(planTarget);
		return json;
	}

	//删除
	@RequestMapping(value="/deletePlanTarget", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject deletePlanTarget(@RequestParam("planTargetIds") List<Integer> planTargetIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planTargetService.deletePlanTarget(planTargetIds, dataState);
		return json;
	}

	//启用
	@RequestMapping(value="/startPlanTarget", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject startPlanTarget(@RequestParam("planTargetIds") List<Integer> planTargetIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planTargetService.deletePlanTarget(planTargetIds, dataState);
		return json;
	}

	//停用
	@RequestMapping(value="/stopPlanTarget", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject stopPlanTarget(@RequestParam("planTargetIds") List<Integer> planTargetIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planTargetService.deletePlanTarget(planTargetIds, dataState);
		return json;
	}





}
